﻿using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FM.矩阵.扩展
{
    public static partial class 扩展方法
    {



        /// <summary>
        /// 串口可以访问返回true
        /// </summary>
        /// <param name="com">The COM.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool 访问测试(this SerialPort com)
        {
            try
            {
                if (com.IsOpen)
                {
                    com.Close();
                    com.Open();
                }
                else
                {
                    com.Open();
                    com.Close();
                }
                return true;
            }
            catch (Exception ee)
            {
                return false;
            }

        }





    }
}
